<?php
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: show.phtml 5115 2010-08-30 03:09:20Z huuphuoc $
 * @since		2.0.6
 */

?>
<div id="login">
    <a id="button-login" href="#"><?php echo $this->translate()->widget('login'); ?></a>
    <div id="login-form" class="modal-box">
        <div class="box-title">
            <div class="wrapper"><h4><?php echo $this->translate()->widget('modal_title'); ?></h4></div>
            <a class="simplemodal-close" href="#"></a>
        </div>
        <div class="box-container">
            <form name="frmLogin" id="frmLogin" action="<?php echo $this->url(array(), 'core_auth_login'); ?>" method="post">
                <p class="guide">
                    <?php echo $this->translate()->widget('login_guide')?> 
                    <a href="#" title="">
                        <?php echo $this->translate()->widget('register_now')?>
                    </a>
                </p>
                <div class="error-box"><ul></ul></div>
                <div class="field username">
                    <label for="login-username"><?php echo $this->translate()->widget('login_form_username')?></label>
                    <input type="text" size="30" name="login[username]" id="login-username"/>
                </div>
                <div class="field password">
                    <label for="login-password"><?php echo $this->translate()->widget('login_form_password')?></label>
                    <input type="password" size="30" name="login[password]" id="login-password"/>
                </div>
                <div class="field remember-me">
                    <label for="login-remember-me"><?php echo $this->translate()->widget('login_form_remember_me')?>
                        <input type="checkbox" size="30" name="login[remember_me]" id="remember-me"/>
                    </label>
                </div>
                <div class="field submit">
                    <input type="submit" name="submit" id="btnLogin" value="<?php echo $this->translate()->widget('login_form_submit')?>"/>
                </div>
                <div class="field links">
                    <ul>
                        <li><a href="<?php echo $this->url(array(), 'core_auth_forgot'); ?>"><?php echo $this->translate()->widget('login_forgot_password')?></a></li>
                    </ul>
                     
                </div>
            </form>
        </div>
    </div>
</div>
<div id="register">
    <a id="button-register" href="#"><?php echo $this->translate()->widget('register')?></a>
    <div id="register-form" class="modal-box">
        <div class="box-title">
            <div class="wrapper"><h4><?php echo $this->translate()->widget('register_modal_title'); ?></h4></div>
            <a class="simplemodal-close" href="#"></a>
        </div>
        <div class="box-container">
             <form name="frmRegister" id="frmRegister" action="<?php //echo $this->url(array(), 'core_auth_login'); ?>" method="post">
				
                <div class="field">
                    <label for="register-name"><?php echo $this->translate()->widget('register_form_name')?></label>
                    <input type="text" size="30" name="register[name]" id="register-name"/>
                </div>
                <div class="field">
                    <label for="register-username"><?php echo $this->translate()->widget('register_form_username')?></label>
                    <input type="text" size="30" name="register[username]" id="register-username"/>
                </div>
                <div class="field">
                    <label for="register-password"><?php echo $this->translate()->widget('register_form_password')?></label>
                    <input type="password" size="30" name="register[password]" id="register-password"/>
                </div>
                <div class="field">
                    <label for="register-confirm-password"><?php echo $this->translate()->widget('register_form_confirm_password')?></label>
                    <input type="password" size="30" name="register[confirm_password]" id="register-confirm-password"/>
                </div>
                <div class="captcha">
                    <label>&nbsp;</label>
                    <div id="register-captcha">
                    </div>
                    <div class="clearfix"></div>
                    
                </div>
                <div class="field submit">
                    <input type="submit" name="register" id="btnRegister" value="<?php echo $this->translate()->widget('register_form_submit')?>"/>
                </div>
             </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $.validator.addMethod(
            "regex",
            function(value, element, regexp) {
                var re = new RegExp(regexp);
                return this.optional(element) || re.test(value);
            },
            "Please check your input."
        );
        $('#button-login').click(function(){
            $('#login-form').modal({
                containerId: 'login-modal',
                onShow: function(){
                    
                    $('#frmLogin').validate({
                        rules:{
                            'login-username':{
                                required: true
                            },
                            'login-password':{
                                required: true
                            }
                        },
                        messages: {
                            'login-username': {
                                required: '<?php echo $this->translate()->widget('login_form_username_required')?>'
                            },
                            'login-password':{
                                required: '<?php echo $this->translate()->widget('login_form_password_required')?>'
                            }
                        },
                        errorContainer: ".error-box",
                        errorLabelContainer: ".error-box ul",
                        wrapper: "li",
                        highlight: function(element, errorClass) {
                            $('#error-box ul').addClass('error');
                            $(element).addClass('error');
                        }
                    });

                }
            });
            return false;
        });
        $('#button-register').click(function(){
            $('#register-form').modal({
                containerId: 'register-modal',
                onShow: function(){
                    Recaptcha.destroy();
                    Recaptcha.create("6LdHatASAAAAAJ-O5wIkrQgS7_ofgG2LRMnbKBif", 'register-captcha', {
                            theme: 'red',
                            tabindex: 0,
                            callback: Recaptcha.focus_response_field
                    });
                },
                onClose: function(){
                    if($('#contact-captcha').length == 1){
                        Recaptcha.destroy();
                        Recaptcha.create("6LdHatASAAAAAJ-O5wIkrQgS7_ofgG2LRMnbKBif", 'contact-captcha', {
                            theme: 'red',
                            tabindex: 0,
                            callback: Recaptcha.focus_response_field
                        });
                    }
                    $.modal.close();
                }
                
            });
            return false;
        });
    });
</script>